package com.fr.dialog;

import com.fr.cell.GUIUtils;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import javax.swing.JPanel;

public class BasicDialog extends BaseDialog
{
  private BasicPane basicPane;
  private boolean addButton = true;

  public static BasicDialog showWindow(Window paramWindow, BasicPane paramBasicPane, String paramString, int paramInt1, int paramInt2)
  {
    if (paramWindow instanceof Frame)
      return new BasicDialog((Frame)paramWindow, paramBasicPane, paramString, paramInt1, paramInt2, true);
    return new BasicDialog((Dialog)paramWindow, paramBasicPane, paramString, paramInt1, paramInt2, true);
  }

  public static BasicDialog showWindow(Window paramWindow, BasicPane paramBasicPane, String paramString, int paramInt1, int paramInt2, boolean paramBoolean)
  {
    if (paramWindow instanceof Frame)
      return new BasicDialog((Frame)paramWindow, paramBasicPane, paramString, paramInt1, paramInt2, paramBoolean);
    return new BasicDialog((Dialog)paramWindow, paramBasicPane, paramString, paramInt1, paramInt2, paramBoolean);
  }

  protected BasicDialog(Frame paramFrame, BasicPane paramBasicPane, String paramString, int paramInt1, int paramInt2, boolean paramBoolean)
  {
    super(paramFrame);
    this.basicPane = paramBasicPane;
    setTitle(paramString);
    setSize(paramInt1, paramInt2);
    this.addButton = paramBoolean;
    initComponents();
  }

  protected BasicDialog(Dialog paramDialog, BasicPane paramBasicPane, String paramString, int paramInt1, int paramInt2, boolean paramBoolean)
  {
    super(paramDialog);
    this.basicPane = paramBasicPane;
    setTitle(paramString);
    setSize(paramInt1, paramInt2);
    this.addButton = paramBoolean;
    initComponents();
  }

  protected void initComponents()
  {
    super.initComponents();
    JPanel localJPanel = (JPanel)getContentPane();
    localJPanel.setLayout(new BorderLayout(0, 4));
    localJPanel.add(this.basicPane, "Center");
    if (this.addButton)
      localJPanel.add(createControlButtonPane(), "South");
    setModal(true);
    GUIUtils.centerWindow(this);
  }

  public void checkValid()
    throws Exception
  {
    if (this.basicPane != null)
      this.basicPane.checkValid();
  }

  public BasicPane getBasicPane()
  {
    return this.basicPane;
  }
}